package com.mxpio.erp.common.oa.entity;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpio.erp.common.annotation.DictValue;
import com.mxpio.erp.common.jpa.policy.ResCodeGeneratorPolicy;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;
import com.mxpioframework.security.entity.Dept;
import com.mxpioframework.security.entity.User;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_OA_FIX_APPLY")
@Schema(description="办公维修申请单")
public class OaFixApply extends BaseEntity {


    @Id
    @Column(name = "BIZ_NO_", updatable = false)
    @Generator(policy = ResCodeGeneratorPolicy.class)
    @Schema(description = "工单编号")
    private String bizNo;

    @Column(name = "DEPT_CODE_")
    @Schema(description = "报修部门编号")
    @Dict(dicCode="deptCode", dicEntity = Dept.class, dicText = "deptName")
    private String deptCode;

    @Column(name = "FIX_TYPE_")
    @Schema(description = "报修项目属性")
    @Dict(dicCode = "MB_ERP_OA_FIX_TYPE")
    @DictValue("10=日常，零星,20=较大型,30=大型")
    private String fixType;

    @Column(name = "DEVICE_CODE_")
    @Schema(description = "设备编号")
    private String deviceCode;

    @Column(name = "DEVICE_NAME_")
    @Schema(description = "设备名称")
    private String deviceName;

    @Column(name = "DEVICE_MODEL_")
    @Schema(description = "设备型号")
    private String deviceModel;

    @Column(name = "DEVICE_FACTORY_NO_")
    @Schema(description = "设备出厂编号")
    private String deviceFactoryNo;

    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @Schema(description = "预约时间")
    @Column(name = "RESERVE_TIME_")
    private Date reserveTime;

    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @Schema(description = "完成时间")
    @Column(name = "FINISH_TIME_")
    private Date finishTime;

    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @Schema(description = "报修时间")
    @Column(name = "REPORT_FIX_TIME_")
    private Date reportFixTime;


    @Column(name = "FAULT_TYPE_")
    @Schema(description = "故障属性") //10 人为 20正常
    @Dict(dicCode="MB_ERP_OA_FIX_FAULT_TYPE")
    @DictValue(value = "10=人为,20=正常")
    private String faultType;

    @Column(name = "EMPLOYEE_ID_")
    @Schema(description = "报修员工工号")
    @Dict(dicCode="username", dicEntity = User.class, dicText = "nickname")
    private String employeeId;


    @Column(name = "REPORT_FIX_REASON_")
    @Schema(description = "报修项目及要求")
    private String reportFixReason;

    @Column(name = "ORDER_STATUS_")
    @Schema(description = "工单状态") //10新增 20审核中 30已完成 40已关闭
    @Dict(dicCode = "MB_ERP_OA_INVOICE_ORDER_STATUS")
    private String orderStatus;

    /**审批状态*/
    @Column(name = "BPMN_STATUS_")
    @Schema(description = "审批状态")
    @Dict(dicCode = "ERP_COMMON_BPMN_STATUS")
    private String bpmnStatus;

    /**审批实例ID*/
    @Column(name = "PROCESS_INSTANCE_ID_")
    @Schema(description = "审批实例ID")
    private String processInstanceId;
}
